<?php

namespace App\Http\Middleware;

use Closure;

class Language
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (empty($request->headers->get('accept-language'))) {
            \App::setLocale(\Config::get('app.locale'));#读取默认语言包
        } else {
            \App::setLocale($request->headers->get('accept-language'));
        }

        return $next($request);
    }
}
